import {defineStore} from "pinia"
import newaxios from "@/service/request"
const useFavorStore = defineStore("favor",{
    state:()=>({
        items:[],
        history:[],
        selectList:[]
    }),
    actions:{
        async getItem(){
            const {data:{data:{items}}} = await newaxios.get("http://codercba.com:1888/api/favor/list")
            this.items = items
            if (this.selectList.length === 0){
                this.selectList = items.map(item => true)
            }
        },
        async getHistory(){
            const res = await newaxios.get("http://codercba.com:1888/api/favor/history")
        },
        changeSelect(i){
            this.selectList[i] = !this.selectList[i]
        }
    }
})

export default useFavorStore